package me.hetong.caigou.mapper;

import me.hetong.caigou.entity.Match;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

public interface MatchMapper {
//    @Update("create table if not exists match\n" +
//            "(\n" +
//            "    id          TEXT\n" +
//            "        primary key,\n" +
//            "    match       TEXT,\n" +
//            "    lun         TEXT,\n" +
//            "    ju          TEXT,\n" +
//            "    red         TEXT,\n" +
//            "    red_team    TEXT,\n" +
//            "    red_score   TEXT,\n" +
//            "    black       TEXT,\n" +
//            "    black_team  TEXT,\n" +
//            "    black_score TEXT,\n" +
//            "    time_type   TEXT,\n" +
//            "    create_time INTEGER,\n" +
//            "    remark      TEXT\n" +
//            ");")
//    void createTable();

    @Insert("INSERT INTO match (id, match, lun, player1 , team1, score1, player2, team2, score2, create_time, remark) VALUES " +
            "(#{m.id}, #{m.match}, #{m.lun},  #{m.player1}, #{m.team1}, #{m.score1}, #{m.player2}, #{m.team2}, #{m.score2}, #{m.createTime}, #{m.remark});\n")
    int insert(@Param("m") Match match);

//    @Select("select *\n" +
//            "from (select aa.name, sum(aa.score) score\n" +
//            "      from (select a.red name, sum(a.red_score) score\n" +
//            "            from match a\n" +
//            "            where a.match = '第19届亚洲运动会中国国家象棋队选拔赛（第二阶段）'\n" +
//            "            group by a.red\n" +
//            "            union all\n" +
//            "            select b.black name, sum(b.black_score) score\n" +
//            "            from match b\n" +
//            "            where b.match = '第19届亚洲运动会中国国家象棋队选拔赛（第二阶段）'\n" +
//            "            group by b.black) aa\n" +
//            "      group by aa.name) bb\n" +
//            "order by bb.score desc")
//    List<PersonBean> list();
}
